package com.mxnet.chongjin.supoman.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.mxnet.chongjin.supoman.R;
import com.mxnet.chongjin.supoman.bean.ConfigGuide;

import java.util.List;

/**
 * author: Administrator
 * email: lcj270018655@163.com
 * date: 2018/5/8
 */

public class LvConfigGuideAdapter extends BaseAdapter {
    public List<ConfigGuide> mList;
    public Context mContext;

    public LvConfigGuideAdapter(Context context, List list) {
        super();
        this.mContext = context;
        this.mList = list;
    }

    @Override
    public int getCount() {
        return mList.size();
    }

    @Override
    public Object getItem(int position) {
        return mList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder;
        if (convertView == null) {
            viewHolder = new ViewHolder();
            convertView = LayoutInflater.from(mContext).inflate(R.layout.item_lv_config_guide, parent, false);
            viewHolder.mImageView = convertView.findViewById(R.id.iv_config_guide);
            viewHolder.mTextView = convertView.findViewById(R.id.tv_config_guide);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }

        viewHolder.mImageView.setImageResource(mList.get(position).getImgUrl());
        viewHolder.mTextView.setText(mList.get(position).getOperate());

        return convertView;
    }

    public static class ViewHolder {
        ImageView mImageView;
        TextView mTextView;
    }
}
